Network devices, such as bridges and routers, forward packets through a network based on addresses in the packets. A network device typically includes a plurality of ports coupled to different network links. The network device typically receives a packet via one port and processes address information in a header of the packet to decide via which other port or ports the network device should transmit the packet. The network device then forwards the packet to the determined one or more other ports. In various network devices, when a packet is received by a network device, the entire packet is stored in a packet memory. The packet is processed, using information from a header of the packet, at least to determine the port or ports to which to forward the packet. The packet is then enqueued in one or more transmit queues corresponding to the determined port or ports. Subsequently, when the packet is scheduled for transmission, the packet is retrieved from the packet memory for forwarding to the determined port or ports. After the packet is retrieved from the packet memory, header alteration is performed, if needed, to modify the header of the packet. The packet is then forwarded to the determined port or ports for transmission of the packet from the network device.
Because header alteration is performed after the packet is retrieved from the packet memory for transmission of the packet, a packet descriptor that includes information needed for header information is typically placed in a transmit queue, and then the information is used to perform header alteration when the packet descriptor is dequeued from the transmit queue and the associated packet is retrieved from the packet memory for transmission of the packet.